import errors from "restify-errors";
import { EntityRepository } from "typeorm";

import { Bec } from "@src/apps/goods/entities/bec.entity"
import { ValidateRepository } from "@src/lib/db/postgres/validate.repository";

@EntityRepository(Bec)
export class BecRepository extends ValidateRepository<Bec> {
    async getIP(): Promise<string|undefined> {
        const user = await this.findOne(0);
        if (user === undefined){
            return user;
        }
        return user.ip;
    }
    async getAll(): Promise<Bec[]|string> {
        const users = await this.find();
        if (users === undefined){
            return 'not found bec';
        }
        return users;
    }
}